﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;

namespace DataAccess.Classes
{
   public class DiaDiem1
    {

       
        #region Khai bao cac truong

        public int ID { get; set; }
        public string TenDiaDiem { get; set; }
        public string ThongTin { get; set; }
        public bool TinhTrang { get; set; }

        #endregion
        #region Phuong thuc tao lap mac dinh

        public DiaDiem1() { }

        #endregion
        

        #region Hien thi danh sach

        public static List<DiaDiem1> LayDanhSachTheoTinhTrang()
        {
            try
            {
                return CBO.FillCollection<DiaDiem1>(DataProvider.Instance.ExecuteReader("DiaDiem_AllTinhTrang"));
            }
            catch
            {
                return null;
            }
        }
        public static List<DiaDiem1> TimKiem(string paramater)
        {
            try
            {
                return CBO.FillCollection<DiaDiem1>(DataProvider.Instance.ExecuteReader("DiaDiem_TimKiem", paramater));
            }
            catch
            {
                return null;
            }
        }
        public static List<DiaDiem1> LocTheoTinhTrangDuocHienThiTrangChu(bool tinhtrang)
        {
            try
            {
                return CBO.FillCollection<DiaDiem1>(DataProvider.Instance.ExecuteReader("DiaDiem_LocTheoTinhTrangDuocHienThiTrangChu",tinhtrang));
            }
            catch
            {
                return null;
            }
        }
        public static List<DiaDiem1> LayDanhSach()
        {
            try
            {
                return CBO.FillCollection<DiaDiem1>(DataProvider.Instance.ExecuteReader("DiaDiem_All"));
            }
            catch
            {
                return null;
            }
        }
        public static DiaDiem1 LayID(int id)
        {
            try
            {
                return CBO.FillObject<DiaDiem1>(DataProvider.Instance.ExecuteReader("DiaDiem_LayTheoID", id));
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Them, Xoa, Cap nhat

        public static bool Them(DiaDiem1 diadiem)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQueryWithOutput("ID", "DiaDiem_Them", diadiem.ID, diadiem.TenDiaDiem, diadiem.ThongTin, diadiem.TinhTrang);
                return Convert.ToInt32(rs)>0;
            }
            catch
            {
                return false;
            }     
        }
        public static bool CapNhat(DiaDiem1 diadiem)
        {
            object rs = DataProvider.Instance.ExecuteNonQuery("DiaDiem_CapNhat", diadiem.ID, diadiem.TenDiaDiem, diadiem.ThongTin, diadiem.TinhTrang);
            return Convert.ToInt32(rs) > 0;
        }
        public static bool Xoa(int id)
        {
            try
            {
                int rs = DataProvider.Instance.ExecuteNonQuery("DiaDiem_Xoa", id);
                return rs > 0;
            }
            catch
            {
                return false;
            }
        }
        #endregion

        #region Dem



        #endregion

    }
}
